package cn.coders.haoniu.caipiao;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import cn.coders.haoniu.caipiao.dao.DdetailDao;
import cn.coders.haoniu.caipiao.entity.Ddetail;
import cn.coders.net.application.utils.logger.LoggerNames;
import cn.coders.net.application.utils.logger.LoggerUtil;


/**
 * 定时任务中心
 */
@Component("taskJob")
public class QuartzCenter {
    /**
     * 日志操作
     */
    private static final Logger logger = Logger.getLogger(LoggerNames.WEB_LOGGER);
    /**
     * 操作名称
     */
    private static final String OPERATION_NAME = "\n【QuartzCenter- 定时任务中心-日志】-->";

    @Autowired
    DdetailDao detailDao;


    /**
     * 自动收取邮件，每隔10分钟收取邮件
     */
    @Scheduled(cron = "0/5 * * * * * ")
    public void autoReciveMail() {
        LoggerUtil.info(logger, OPERATION_NAME + "任务启动");
        LoggerUtil.info(logger, OPERATION_NAME + detailDao);
        Ddetail d = new Ddetail();
        d.setName("测试");
        d.setBonus(452);
        d.setId(4512251);
        d.setPhone("15" + RandomStringUtils.randomNumeric(9));
        detailDao.save(d);
    }
}